package hibernateDao;

import java.rmi.UnmarshalException;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
public class HibernateDao {
	private static HibernateDao instancia = null;
	private static SessionFactory sf = null;
	

	public static HibernateDao getInstancia(){
		if(instancia == null){
			sf = HibernateUtil.getSessionFactory();
			instancia = new HibernateDao();
		} 
		return instancia;
	}
	
	public void agregarEntity(Object entity)throws UnmarshalException{
			Session session = sf.openSession();
			session.beginTransaction();
			session.persist(entity);
			session.flush();
			session.getTransaction().commit();
			session.close();
		
	}

}
